package cn.itcast.service.impl;

import cn.itcast.dao.OrderDao;
import cn.itcast.dao.PayDao;
import cn.itcast.pojo.Order;
import cn.itcast.service.PayService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@Service(version = "1.0.0")
public class PayServiceImpl implements PayService {

    @Autowired
    private PayDao payDao;

    @Autowired
    private OrderDao orderDao;

    /**
     * 修改订单支付状态的方法
     * @param result   封装的orderid
     */
    @Override
    public void updatePayStatus(Map<String, String> result) {
        // 查询出order对象
        String orderId = result.get("out_trade_no");
        Order order = orderDao.findByid(orderId);

        // 设置支付状态
        order.setPayStatus(0);
        payDao.updatePayStatus(orderId,order.getPayStatus());
    }
}
